package com.lxmes.pm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.pm.domain.AMeeting;
import com.lxmes.pm.service.IAMeetingService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 学术会议Controller
 * 
 * @author zhangzhiyu
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/pm/meeting")
public class AMeetingController extends BaseController
{
    @Autowired
    private IAMeetingService aMeetingService;

    /**
     * 查询学术会议列表
     */
    @PreAuthorize("@ss.hasPermi('pm:meeting:list')")
    @GetMapping("/list")
    public TableDataInfo list(AMeeting aMeeting)
    {
        startPage();
        List<AMeeting> list = aMeetingService.selectAMeetingList(aMeeting);
        return getDataTable(list);
    }

    /**
     * 导出学术会议列表
     */
    @PreAuthorize("@ss.hasPermi('pm:meeting:export')")
    @Log(title = "学术会议", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AMeeting aMeeting)
    {
        List<AMeeting> list = aMeetingService.selectAMeetingList(aMeeting);
        ExcelUtil<AMeeting> util = new ExcelUtil<AMeeting>(AMeeting.class);
        util.exportExcel(response, list, "学术会议数据");
    }

    /**
     * 获取学术会议详细信息
     */
    @PreAuthorize("@ss.hasPermi('pm:meeting:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aMeetingService.selectAMeetingById(id));
    }

    /**
     * 新增学术会议
     */
    @PreAuthorize("@ss.hasPermi('pm:meeting:add')")
    @Log(title = "学术会议", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AMeeting aMeeting)
    {
        return toAjax(aMeetingService.insertAMeeting(aMeeting));
    }

    /**
     * 修改学术会议
     */
    @PreAuthorize("@ss.hasPermi('pm:meeting:edit')")
    @Log(title = "学术会议", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AMeeting aMeeting)
    {
        return toAjax(aMeetingService.updateAMeeting(aMeeting));
    }

    /**
     * 删除学术会议
     */
    @PreAuthorize("@ss.hasPermi('pm:meeting:remove')")
    @Log(title = "学术会议", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aMeetingService.deleteAMeetingByIds(ids));
    }
}
